//package com.corpgovernment.common.operatelog.aspect;
//
//
//import com.corpgovernment.common.operatelog.OperateLog;
//import com.corpgovernment.common.operatelog.bo.OprerateLogBo;
//import com.corpgovernment.organization.operatelog.service.OperateLogService;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.After;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Method;
//
///**
// * @ClassName: OperateLogAspect
// * @description: TODO
// * @author: jiang.luo
// * @date: Created in 19:42 2020/1/3
// * @Version: 1.0
// **/
//@Slf4j
//@Aspect
//@Component
//public class OperateLogAspect {
//    @Autowired
//    private OperateLogService operateLogService;
//
//    /**
//     * 这里我们使用注解的形式
//     * 当然，我们也可以通过切点表达式直接指定需要拦截的package,需要拦截的class 以及 method
//     * 切点表达式:   execution(...)
//     */
//    @Pointcut("@annotation(com.corpgovernment.common.operatelog.OperateLog)")
//    public void logPointCut() {
//    }
//
//
//    /**
//     * 环绕通知 @Around  ， 当然也可以使用 @Before (前置通知)  @After (后置通知)
//     *
//     * @param point
//     * @return
//     * @throws Throwable
//     */
//    @Around("logPointCut()")
//    public Object around(ProceedingJoinPoint point) throws Throwable {
//        Object result = point.proceed();
//        try {
//            saveLog(point);
//        } catch (Exception e) {
//            log.error("保存失败！原因：{}",e.getMessage());
//        }
//        return result;
//    }
//
//    @After("logPointCut()")
//    public void after(JoinPoint point) throws Throwable {
//        try {
////            saveLog(point, time);
//        } catch (Exception e) {
//            log.error("保存失败！原因：{}",e.getMessage());
//        }
//    }
//
//
//
//    /**
//     * 保存日志
//     *
//     * @param joinPoint
//     */
//    private void saveLog(ProceedingJoinPoint joinPoint) {
//        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
//        Method method = signature.getMethod();
//        OprerateLogBo sysLogBO = new OprerateLogBo();
//        OperateLog sysLog = method.getAnnotation(OperateLog.class);
//        if (sysLog != null) {
//            //注解上的描述
//            sysLogBO.setRemark(sysLog.value());
//        }
//        //请求的 类名、方法名
//        String className = joinPoint.getTarget().getClass().getName();
//        String methodName = signature.getName();
//        sysLogBO.setClassName(className);
//        sysLogBO.setMethodName(methodName);
//        //请求的参数
//        Object[] args = joinPoint.getArgs();
//        try {
////            List<String> list = Lists.newArrayList();
////            for (Object o : args) {
////                list.add(new Gson().toJson(o));
////            }
////            sysLogBO.setParams(list.toString());
//
//            sysLogBO.setParams(JSON.toJSONString(args));
//        } catch (Exception e) {
//            log.error("调用保存方法失败！原因:{}",e.getMessage());
//        }
//        operateLogService.save(sysLogBO);
//    }
//
//}
